package com.qqhf.hitfood.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.qqhf.common.entity.AjaxResult;
import com.qqhf.common.entity.PageEntity;
import com.qqhf.hitfood.bean.core.BaseController;
import com.qqhf.hitfood.bean.entity.BizOrderComment;
import com.qqhf.hitfood.service.IBizOrderCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

//@Api(tags = "B - 订单评论(弃用)")
//@RestController
//@RequestMapping("/biz/order/comment")
public class BizOrderCommentController extends BaseController {
    @Autowired
    private IBizOrderCommentService bizOrderCommentService;

    @GetMapping("/page")
    public AjaxResult page(PageEntity pageEntity, BizOrderComment bizOrderComment) {
        return AjaxResult.success(bizOrderCommentService.page(pageEntity.toPage(), Wrappers.lambdaQuery(bizOrderComment)));
    }

    @GetMapping("/list")
    public AjaxResult list(BizOrderComment bizOrderComment) {
        return AjaxResult.success(bizOrderCommentService.list(Wrappers.lambdaQuery(bizOrderComment)));
    }

    @PostMapping("/add")
    public AjaxResult add(@RequestBody BizOrderComment bizOrderComment) {
        return AjaxResult.success(bizOrderCommentService.save(bizOrderComment));
    }

    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody BizOrderComment bizOrderComment) {
        return AjaxResult.success(bizOrderCommentService.updateById(bizOrderComment));
    }

    @DeleteMapping("/delete/{ids}")
    public AjaxResult delete(@PathVariable Integer[] ids) {
        return AjaxResult.success(bizOrderCommentService.removeByIds(Arrays.asList(ids)));
    }

    @GetMapping(value = "/detail/{id}")
    public AjaxResult detail(@PathVariable("id") Integer id) {
        return AjaxResult.success(bizOrderCommentService.getById(id));
    }
}
